using RayDen.Library.Core.Primitives;

namespace RayDen.Optix.Engine.Core
{
    public unsafe struct SPD16
    {
        public float lambdaMin, lambdaMax, delta;
        public fixed float samples[16];

        public SPD16(IWavelengthDependentValue spd, float lmin, float lmax)
        {
            delta = (lmax - lmin)/16;
            lambdaMin = lmin;
            lambdaMax = lmax;
            float l = lmin;
            for (int i = 0; i < 16; i++)
            {
                this[i] = spd.Sample(l);
                l += delta;
            }
        }

        public float this[int index]
        {
            get
            {
                fixed (float* ptr = samples)
                {
                    return ptr[index];
                }
            }
            set
            {
                fixed (float* ptr = samples)
                {
                    ptr[index] = value;
                }
            }
        }
    }
}